<!DOCTYPE html>
<html>
    <head>

    </head>
    <body>
        <h1> 案例01 声明变量</h1>
        <script>
        var x = 2;
        var y = 3;
        var z = 2+3;
        document.write(x + "<br/>");
        document.write(y+"<br/>");
        document.write(z+"<br/>");
        </script>

        <br/>
        <br/>
        <br/>
        <br/>
        <br/>
        <h1>案例02 数据类型</h1>
        <script>
        var pi =3.14;
        var name = "Bill Gates";
        var answer = "Yes I am!";

        document.write(pi +"<br/>");
        document.write(name + "<br/>");
        document.write(answer + "<br/>")
        </script>
<br/>
        <br/>
        <br/>
        <br/>
        <br/>
        <h1>案例03 声明变量，并向其赋值</h1>
        <p id = "demo"></p>
        <script>
        var carname="Volvo";
        document.getElementById("demo").innerHTML = carname;
        </script>

    <br/>
        <br/>
        <br/>
        <br/>
<h1>案例03 假设 y=5，计算 x=y+2，并显示结果。</h1>
<button onclick="myFunction()">点击这里</button>

<p id="demo1"></p>

<script>
function myFunction()
{
var y=5;
var x=y+2;
var demoP=document.getElementById("demo1")
demoP.innerHTML="x=" + x;
}
</script>
    </body>

</html>